import 'package:demo/common/extension/ex_getx.dart';
import 'package:demo/common/extension/ex_widget.dart';
import 'package:demo/common/routers/route_names.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'test_ctrl.dart';

class TestPage extends GetWidget<TestCtrl> {
  TestPage({Key? key}) : super(key: key);

  static open() {
    Get.toNamed(RouteNames.test, preventDuplicates: false);
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Container(
            color: Colors.blue,
            width: 100.w,
            height: 20.w,
            child: GetBuilder<TestCtrl>(
              init: ctrl,
              global: false,
              builder: (ctrl) {
                return Text(ctrl.va.value.toString());
              },
            ),
          ).onTap(() {
            ctrl.va.value++;
          }),
          Text("跳转").onTap(TestPage.open),
        ],
      ),
    );
  }
}
